package com.gaohe.scp.service.impl;

import java.util.List;
import com.gaohe.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gaohe.scp.mapper.CsCarVisitMapper;
import com.gaohe.scp.domain.CsCarVisit;
import com.gaohe.scp.service.ICsCarVisitService;

/**
 * 车辆浏览Service业务层处理
 * 
 * @author liuxiangyu
 * @date 2025-03-25
 */
@Service
public class CsCarVisitServiceImpl implements ICsCarVisitService 
{
    @Autowired
    private CsCarVisitMapper csCarVisitMapper;



    @Override
    public int upsertVisit(CsCarVisit csCarVisit)
    {
//        csCarVisit.setCreateTime(DateUtils.getNowDate());
        return csCarVisitMapper.upsertVisit(csCarVisit);
    }
    @Override
    public int decrementCollectByCarId(Long carId)
    {
//        csCarVisit.setUpdateTime(DateUtils.getNowDate());
        return csCarVisitMapper.decrementCollectByCarId(carId);
    }

    @Override
    public int upsertCollect(CsCarVisit csCarVisit)
    {
//        csCarVisit.setCreateTime(DateUtils.getNowDate());
        return csCarVisitMapper.upsertCollect(csCarVisit);
    }

    /**
     * 查询车辆浏览
     * 
     * @param visitId 车辆浏览主键
     * @return 车辆浏览
     */
    @Override
    public CsCarVisit selectCsCarVisitByVisitId(Long visitId)
    {
        return csCarVisitMapper.selectCsCarVisitByVisitId(visitId);
    }

    /**
     * 查询车辆浏览列表
     * 
     * @param csCarVisit 车辆浏览
     * @return 车辆浏览
     */
    @Override
    public List<CsCarVisit> selectCsCarVisitList(CsCarVisit csCarVisit)
    {
        return csCarVisitMapper.selectCsCarVisitList(csCarVisit);
    }

    /**
     * 新增车辆浏览
     * 
     * @param csCarVisit 车辆浏览
     * @return 结果
     */
    @Override
    public int insertCsCarVisit(CsCarVisit csCarVisit)
    {
        csCarVisit.setCreateTime(DateUtils.getNowDate());
        return csCarVisitMapper.insertCsCarVisit(csCarVisit);
    }

    /**
     * 修改车辆浏览
     * 
     * @param csCarVisit 车辆浏览
     * @return 结果
     */
    @Override
    public int updateCsCarVisit(CsCarVisit csCarVisit)
    {
        csCarVisit.setUpdateTime(DateUtils.getNowDate());
        return csCarVisitMapper.updateCsCarVisit(csCarVisit);
    }

    /**
     * 批量删除车辆浏览
     * 
     * @param visitIds 需要删除的车辆浏览主键
     * @return 结果
     */
    @Override
    public int deleteCsCarVisitByVisitIds(Long[] visitIds)
    {
        return csCarVisitMapper.deleteCsCarVisitByVisitIds(visitIds);
    }

    /**
     * 删除车辆浏览信息
     * 
     * @param visitId 车辆浏览主键
     * @return 结果
     */
    @Override
    public int deleteCsCarVisitByVisitId(Long visitId)
    {
        return csCarVisitMapper.deleteCsCarVisitByVisitId(visitId);
    }

    //根据车辆id查询浏览量和收藏量
    @Override
    public CsCarVisit selectCsCarVisitByCarId(Long carId) {
        return csCarVisitMapper.selectCsCarVisitByCarId(carId);
    }
}
